package com.ynding.cloud.auth.api.authentication.api;

import com.ynding.cloud.auth.api.authentication.model.bo.UserInfo;
import com.ynding.cloud.common.model.bo.ResponseBean;
import io.swagger.annotations.ApiOperation;
import org.springframework.http.HttpHeaders;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * <p> 认证服务api</p>
 *
 * @author ynding
 * @version 2021/8/17
 **/
public interface IAuthApiService {


    /**
     * 注册
     * @param userInfo
     * @return
     */
    ResponseBean register(UserInfo userInfo);

    /**
     * 登录并获取token
     * @param userInfo
     * @return
     */
    ResponseBean<String> login(UserInfo userInfo);

    /**
     * 刷新token
     * @param token
     * @return
     */
    ResponseBean refreshToken(String token);

    /**
     * 调用签权服务，判断用户是否有权限
     *
     * @param authorization Bearer token
     * @param url
     * @param method
     * @return true/false
     */
    ResponseBean<Boolean> auth(@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization, @RequestParam("url") String url, @RequestParam("method") String method);

    /**
     * 是否无效authentication
     * @param authentication
     * @return
     */
    @ApiOperation(value = "是否无效authentication", produces = "application/json")
    ResponseBean invalidJwtAccessToken(@RequestParam("authentication") String authentication);

    /**
     * @param authentication
     * @param url
     * @param method
     * @return
     */
    boolean hasPermission(String authentication, String url, String method);
}
